package org.piggy.common.config;

import java.io.Serial;
import java.io.Serializable;
import java.util.Objects;


public class ServiceInstance implements Serializable {

	@Serial
	private static final long serialVersionUID = -7559569289189228478L;

	//ip:port
	protected String serviceInstanceId;

	//serviceId:version
	protected String serviceName;

	protected String ip;

	protected int port;

	protected String tags;

	protected Integer weight;

	protected long registerTime;

	protected boolean enable = true;

	protected String version;

	protected boolean gray;

	public ServiceInstance() {
		super();
	}

	public String getServiceName() {
		return serviceName;
	}

	public void setServiceName(String serviceName) {
		this.serviceName = serviceName;
	}

	public String getServiceInstanceId() {
		return serviceInstanceId;
	}

	public void setServiceInstanceId(String serviceInstanceId) {
		this.serviceInstanceId = serviceInstanceId;
	}

	public String getTags() {
		return tags;
	}

	public void setTags(String tags) {
		this.tags = tags;
	}

	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

	public int getPort() {
		return port;
	}

	public void setPort(int port) {
		this.port = port;
	}

	public Integer getWeight() {
		return weight;
	}

	public void setWeight(Integer weight) {
		this.weight = weight;
	}

	public long getRegisterTime() {
		return registerTime;
	}

	public void setRegisterTime(long registerTime) {
		this.registerTime = registerTime;
	}

	public boolean isEnable() {
		return enable;
	}

	public void setEnable(boolean enable) {
		this.enable = enable;
	}

	public String getVersion() {
		return version;
	}

	public void setVersion(String version) {
		this.version = version;
	}

	public boolean isGray() {
		return gray;
	}

	public void setGray(boolean gray) {
		this.gray = gray;
	}

	@Override
	public boolean equals(Object o) {
		if(this == o) {
			return true;
		}
		if(getClass() != o.getClass()) {
			return false;
		}
		ServiceInstance serviceInstance = (ServiceInstance)o;
		return Objects.equals(serviceInstanceId, serviceInstance.serviceInstanceId);
	}
	
	@Override
	public int hashCode() {
		return Objects.hash(serviceInstanceId);
	}

	@Override
	public String toString() {
		return "ServiceInstance{" +
				"serviceInstanceId='" + serviceInstanceId + '\'' +
				", serviceName='" + serviceName + '\'' +
				", ip='" + ip + '\'' +
				", port=" + port +
				", tags='" + tags + '\'' +
				", weight=" + weight +
				", registerTime=" + registerTime +
				", enable=" + enable +
				", version='" + version + '\'' +
				", gray=" + gray +
				'}';
	}
}
